import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;

//Special type of zone
//Can be a key, which is drawn and sized differently from other zones
public class SafeZone extends Zone{

	private Robot.Alliance alliance;
	private Point upperLeft;
	private int xSize, ySize;
	private boolean isKey;

	SafeZone(Point upperLeft, int xSize, int ySize, Robot.Alliance alliance, boolean key){
		super(upperLeft, xSize, ySize, alliance);
		this.alliance = alliance;
		this.upperLeft = upperLeft;
		this.xSize = xSize;
		this.ySize = ySize;
		this.isKey = key;
	}

	public void drawZone(Graphics page){
		if(alliance == Robot.Alliance.red){
			page.setColor(Zone.fadedRed);
		}
		else if(alliance == Robot.Alliance.blue){
			page.setColor(Zone.fadedBlue);
		}
		else if(alliance == Robot.Alliance.neutral){
			page.setColor(RoboticsProjectPanel.background);

		}
		if(isKey == false){
			page.fillRect(upperLeft.x, upperLeft.y, xSize, ySize);

			page.setColor(RoboticsProjectPanel.background);
			page.fillRect(upperLeft.x + 10, upperLeft.y  +10, xSize - 20, ySize - 20);

			page.setColor(Color.black);
			page.drawString("SafeZone", upperLeft.x + xSize/2, upperLeft.y + ySize/2);

		}
		
		//draw the top of the key (an arc)
		else if(isKey == true)
		{
			if(alliance == Robot.Alliance.red){
				page.fillArc(upperLeft.x, upperLeft.y, 150, 200, -90, 180);
				page.fillRect(0, upperLeft.y, upperLeft.x + 75, 10);
				page.fillRect(0, upperLeft.y + 190, upperLeft.x+75, 10);

				page.setColor(Color.black);
				page.drawString("SafeZone", upperLeft.x + 80, upperLeft.y + 100);
			}
			else if(alliance == Robot.Alliance.blue){
				page.fillArc(upperLeft.x, upperLeft.y, 150, 200, -270, 180);
				page.fillRect(upperLeft.x+75, upperLeft.y, 1200, 10);
				page.fillRect(upperLeft.x+75, upperLeft.y + 190, upperLeft.x+75, 10);

				page.setColor(Color.black);
				page.drawString("SafeZone", upperLeft.x + 5, upperLeft.y + 100);
			}
		}
	}


}
